package Year22_Month05.day30;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/*
1.筛选出年龄超过35的员工
2.筛选出薪资超过5000的员工
 */
public class TestEmployee {
    public static List<Employee> filterEmployeeByAge(List<Employee> list){
        List<Employee> emps = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getAge() > 35){
                emps.add(list.get(i));
            }
        }
        return emps;
    }

    public static List<Employee> filterEmployeeBySalary(List<Employee> list){
        List<Employee> emps = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getSalary() > 5000){
                emps.add(list.get(i));
            }
        }
        return emps;
    }
    public static void main(String[] args) {
        int a = 100;
        List<Employee> emps = Arrays.asList(
                new Employee("张三","男", 20, 5000),
                new Employee("李四","男", 36, 7000),
                new Employee("王五","男", 16, 3000),
                new Employee("赵六","女", 23, 6000),
                new Employee("田七","男", 43, 8000)
        );
        emps.forEach(e ->
                System.out.println(e));

        //emps.sort((e1,e2)-> e1.getAge()-e2.getAge());
        emps.sort((e1,e2)-> {
            System.out.println(a);
            return e1.getAge()-e2.getAge();
        });
        System.out.println(emps);
        System.out.println("***************************************");

        List<Employee> list1 = filterEmployeeByAge(emps);
        System.out.println(list1);

        System.out.println("---------------------------------");
        List<Employee> list2 = filterEmployeeBySalary(emps);
        System.out.println(list2);
    }
}
